package javaRew;

/**
 * Created by xjweng on 2017/1/31.
 */
public class Customer {
    private String CustomerName;
    private String email;

    public Customer(String CustomerName, String email){
        this.CustomerName = CustomerName;
        this.email = email;
    }
    public String getCustomerName() {
        return CustomerName;
    }

    public String getEmail() {
        return email;
    }

    public void setCustomerName(String customerName) {
        CustomerName = customerName;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    //equals()判断两对象是否指向同块内存空间，在此重写，判断两对象内容是否相等则相等，封装类比较都是比较内容
    @Override
    public boolean equals(Object obj) {
        if(!(obj instanceof Customer)){
            return false;
        }
        if(obj == null){
            return false;
        }
        Customer chobj = (Customer) obj;
        if (this.CustomerName.equals(chobj.getCustomerName()) && this.email.equals(chobj.getEmail())){
            return true;
        }else {
            return false;
        }
    }
}
